//
//  NSMutableAttributedString+FIDText.m
//  Gank
//
//  Created by Fidetro on 2017/4/9.
//  Copyright © 2017年 Fidetro. All rights reserved.
//

#import "NSMutableAttributedString+FIDText.h"

@implementation NSMutableAttributedString (FIDText)
- (NSMutableAttributedString *)attributeStrings:(NSArray *)strs attributes:(NSArray *)attrs
{
    
    for (NSInteger index = 0; index < strs.count; index++) {
        NSString *str = strs[index];
        NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]initWithString:str];
        for (id attribute in attrs[index]) {
            if ([attribute isKindOfClass:[UIColor class]]) {
                [attrString addAttribute:NSForegroundColorAttributeName value:attribute range:NSMakeRange(0, str.length)];
            }else if ([attribute isKindOfClass:[UIFont class]]){
                [attrString addAttribute:NSFontAttributeName value:attribute range:NSMakeRange(0, str.length)];
            }else if ([attribute isKindOfClass:[NSNumber class]]){
                [attrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, str.length)];
            }
        }
        
        [self appendAttributedString:attrString];
    }
    
    
    return self;
}
@end
